<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>客户查询管理</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	$(document).ready(function() {

		$("#s2id_province").find("a:first").find("span:first").html("请选择市区");
		$("#province").val("");
	});
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}
	function findArea(elem) {
		var provinceId = $(elem).val();
		$("#city option:not(:first)").remove();
		$("#city").val("-1");
		if (provinceId == "-1") {
			$("#s2id_city").find("a:first").find("span:first").html("请选择市区");
			return false;
		}

		$.ajax({
			type : "post",
			data : "parent_id=" + provinceId,
			url : "${ctx}/crm/business/customer/findCity",
			success : function(data) {
				for ( var i = 0; i < data.length; i++) {
					var nodes = "<option value='"+data[i].id+"'>"
							+ data[i].name + "</option>";
					$("#city").append(nodes);
				}
			}
		});
		$("#s2id_city").find("a:first").find("span:first").html("请选择市区");
	}
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active">
			<a href="javascript:void(0)">客户列表</a>
		</li>
	</ul>

	<div class="breadcrumb">
		<div style="width:auto;display: inline;float: left;">
			<form:form id="searchForm" modelAttribute="findCustomer" action="${ctx}/crm/findcustomer/findCustomer/searchCustomer" method="post" style="display:inline;" class="form-search">
				<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
				<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}" />
				<ul class="ul-form" >
					<li>
						<label>公司名：</label>
						<%-- <form:select path="name" htmlEscape="false" maxlength="100" class="input-medium">
							<form:option value="">请选择</form:option>
							<c:forEach items="${customerNames }" var="customerName">
								<form:option value="${customerName }">${customerName }</form:option>
							</c:forEach>
						</form:select> --%>
						<form:input path="name"  maxlength="100" class="input-medium"/>
					</li>
					<li>
						<label>行业名：</label>
						<form:select path="trade" htmlEscape="false" maxlength="100" class="input-medium">
							<form:option value="">请选择</form:option>
							<c:forEach items="${industryNames }" var="industryName">
								<form:option value="${industryName }">${industryName }</form:option>
							</c:forEach>
						</form:select>
					</li>
					<li>
						<label>省：</label>
						<form:select class="input-medium" id="province" path="province" onchange="findArea(this)">
							<form:option value="">请选择省份</form:option>
							<c:forEach items="${area}" var="area">
								<form:option value="${area.id}">${area.name}</form:option>
							</c:forEach>
						</form:select>
					</li>
					<li>
						<label>市：</label>
						<form:select class="input-medium" id="city" path="city">
							<form:option value="">请选择市区</form:option>
						</form:select>
					</li>
					<li class="btns">
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" />
					</li>
					<%-- <span style="float: left; margin-left: 250px; margin-top: 5px;" class="clearfix">
				<shiro:hasPermission name="findcustomer:findCustomer:mycollect">
					<input id="myCollect" onclick="javascrpt:window.location='${ctx}/crm/findcustomer/findCustomer/myCollect'" class="btn btn-primary" type="button" value="我的收藏" />
				</shiro:hasPermission>
			</span> --%>
				</ul>
			</form:form>
		</div>
		<div style="padding-top: 4.3px;">
			<form action="${ctx}/crm/findcustomer/findCustomer/exportAll" style="display: inline;">
				<input type="hidden" name="customerIds" value='<c:forEach items="${page.list }" var="customer">
			${customer.id },
			</c:forEach>' />
				<shiro:hasPermission name="findcustomer:findCustomer:customerExport">
					<input id="export" class="btn btn-primary" type="submit" value="导出" />
				</shiro:hasPermission>
			</form>
		</div>
	</div>
	<sys:message content="${message}" />
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>公司名</th>
				<!-- <th>地址</th> -->
				<th>状态</th>
				<th>添加人</th>
				<th>添加时间</th>
				<th>最后修改人</th>
				<th>最后修改时间</th>
				<shiro:hasPermission name="findcustomer:findCustomer:deleteCustomer">
					<th>操作</th>
				</shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="findCustomer">
				<tr>
					<td>
						<a href="${ctx}/crm/findcustomer/findCustomer/form?id=${findCustomer.id}"> ${findCustomer.name} </a>
					</td>
					<%-- <td>${findCustomer.address}</td> --%>
					<td>${findCustomer.statusId}</td>
					<td>${findCustomer.createUser}</td>
					<td>
						<fmt:formatDate value="${findCustomer.createDate}" pattern="yyyy-MM-dd HH:mm:ss" />
					</td>
					<td>${findCustomer.updateUser}</td>
					<td>
						<fmt:formatDate value="${findCustomer.updateDate}" pattern="yyyy-MM-dd HH:mm:ss" />
					</td>

					<shiro:hasPermission name="findcustomer:findCustomer:deleteCustomer">
						<td>
							<a href="${ctx}/crm/findcustomer/findCustomer/delete?id=${findCustomer.id}" onclick="return confirmx('确认要删除该客户吗？', this.href)">删除</a>
						</td>
					</shiro:hasPermission>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>